package com.example.m3;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
//@RabbitListener(queues = "helloworld") //rabbit监听
public class Consumer {
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue, // 随机命名,非持久,独占,自动删除
            exchange = @Exchange(name = "logs", declare = "false") //declare = "false":使用已经存在的交换机而不创建
    ))
    public void receive1(String s) {
        System.out.println("消费者1收到： "+s);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue,
            exchange = @Exchange(name = "logs", declare = "false")
    ))
    public void receive2(String s) {
        System.out.println("消费者2收到： "+s);
    }



}
